//JavaScript Document



function createuser()
{
   if(document.getElementById('name').value=="")	
	{
		alert('Please Enter Name Field');
	    document.getElementById('name').focus();
		return false;
	}
    
	if(document.admin.usertype[document.admin.usertype.selectedIndex].value==0)
	{
	  alert("Please Select Usertype Field");
	  document.admin.usertype.focus();
	   return false;
	}
	else {
		
		if($("#usertype").val()==2){
			if($("#zone").val()==0) {
				alert('Please Select Zone');
				$("#zone").focus();
				return false;
			}
		}
		if($("#usertype").val()==3){
			if($("#zone").val()==0) {
				alert('Please Select Zone');
				$("#zone").focus();
				return false;
			}
			if($("#circle").val()==0) {
				alert('Please Select Circle');
				$("#circle").focus();
				return false;
			}
		}
		if($("#usertype").val()==4){
			if($("#zone").val()==0) {
				alert('Please Select Zone');
				$("#zone").focus();
				return false;
			}
			if($("#circle").val()==0) {
				alert('Please Select Circle');
				$("#circle").focus();
				return false;
			}
			if($("#division").val()==0) {
				alert('Please Select Division');
				$("#division").focus();
				return false;
			}

		}
		if($("#usertype").val()==5){
			if($("#zone").val()==0) {
				alert('Please Select Zone');
				$("#zone").focus();
				return false;
			}
			if($("#circle").val()==0) {
				alert('Please Select Circle');
				$("#circle").focus();
				return false;
			}
			if($("#division").val()==0) {
				alert('Please Select Division');
				$("#division").focus();
				return false;
			}
			if($("#sub_division").val()==0) {
				alert('Please Select Sub Division');
				$("#sub_division").focus();
				return false;
			}
		}
	}
	
	if($("#designation").val()==0){
		alert('Please Select Designation');
		$("#designation").focus();
		return false;
	
	}
	
	if(document.getElementById('login_id').value=="")	
	{
		alert('Please Enter Loginid Field');
	    document.getElementById('login_id').focus();
		return false;
	}
	if(document.getElementById('password').value=="")	
	{
		alert('Please Enter Password Field');
	    document.getElementById('password').focus();
		return false;
	}
	if(document.getElementById('password').value.length<6 || document.getElementById('password').value.length>15)
	{
		alert('Please Enter Password Min 6 Charecter and Max 15 Charecter');
		document.getElementById('password').focus();
		return false;
		
	}
	
	if(document.getElementById('password').value!=document.getElementById('repeatpassword').value)	
	{
		alert('Please Check!Password and Repeat Password Must be Equal');
	    document.getElementById('repeatpassword').focus();
		return false;
	}
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById('emailid').value;
   if(reg.test(address) == false)
   {
      alert('Invalid Email Address');
	  document.getElementById('emailid').focus();
      return false;
   }
	

}



function check_usertype(value){
$(".user_type").hide();
	if(value==2){
	$("#zone").show();
	}
	else if(value==3){
	$("#zone,#circle").show();
	}
	else if(value==4){
	$("#zone,#circle,#division").show();
	}
	else if(value==5){
		$("#zone,#circle,#division,#sub_division").show();
	}
}

function load_circle(value){
$.get("call_ajax_create_user.php?load_circle="+value,function(data){
$("#circle").html(data);															  
});
}

function load_division(value){
$.get("call_ajax_create_user.php?load_division="+value,function(data){
$("#division").html(data);															  
});
}

function load_sub_div(value){
$.get("call_ajax_create_user.php?load_sub_div="+value,function(data){
$("#sub_division").html(data);															  
});	
	
}